home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 4_0 / UUPC3 / MAC_SPEC / HOSTPATH.C < prev    next >
Text File  |  1991-12-02  |  1KB  |  70 lines

  1. #ifdef THINK_C
  2. # include "unixlibproto.h"
  3. #endif THINK_C
  4.  
  5. #include    "host.h"
  6. #ifndef NULL
  7. #define NULL 0L
  8. #endif
  9.  
  10. /* canonical name conversion routines
  11.  
  12.     importpath    canonical -> host
  13.     exportpath    host -> canonical
  14.  
  15.     host        your local pathname format
  16.     canonical    unix style
  17. */
  18.  
  19. importpath( host, canon )
  20. char * host;
  21. char * canon;
  22. {
  23.     int i;
  24.     strcpy(host, canon);
  25. }
  26.  
  27. exportpath( canon, host )
  28. char * host;
  29. char * canon;
  30. {
  31.     /* copy the string replacing ":" by "/" */
  32.     register    char *h = host,
  33.                      *c = canon;
  34.                         
  35.     while (*c = *h++) {
  36.         if (*c == ':') *c = '/';
  37.         c++;
  38.     }
  39. }
  40.  
  41. /* converts Unix path to Mac path syntax */
  42. /* Permit full Mac-style "diskname:dir:dir:...:file" specifications... dplatt */
  43. cnvMac (upath, mpath)
  44. char    * upath,
  45.         * mpath;
  46. {
  47.     register    char    *u = upath,
  48.                         *m = mpath;
  49.     int            vRef, len;
  50.     
  51.     if (*u == SEPCHAR) {
  52.         /* put volume name on the front */
  53.         (void)GetVol((StringPtr)m, &vRef);
  54.         len = (int)(m[0]);
  55.         PtoCstr(m);
  56.         m += len;
  57.     }
  58.     else if (strchr(u, DIRCHAR) == NULL) {
  59.         *m++ = ':';
  60.     }
  61.     
  62.     while ( *m = *u++ ) {
  63.         if (*m == SEPCHAR) *m = ':';
  64.         m++;
  65.     }
  66. }
  67.  
  68.  
  69.  
  70.